import {GET_USERINFO} from '../mutations-type.js'
import {getLogin} from '../../api/common'
// import { getPDate } from '../../api/getPDate.js'
const login= {
    state: {
        userName:"admin",
        userInfo: {}
    },
    mutations: {
        [GET_USERINFO](state,obj) {
            state.userInfo= obj
        }
    },
    actions: {
        async getLogin({commit},obj) {
            let userInfor = await getLogin(obj)
            
            if(!userInfor.data.status) {
                localStorage.token=userInfor.data.token
                commit("GET_USERINFO",userInfor.data.data)
                
            }
            return userInfor
        },
        // async getPDate({commit},obj) {
        //     let date =await getPDate(obj)
        //     commit([GET_USERINFO])
        //     return date
        // }
    }
}
export default login;